<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>青鸟影院管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/common.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
    <script type="text/javascript">
    
    var cc = 0;
    ajaxCount();
    
    
	function ajaxCount() {
		$.ajax({
			url : "/SSM_CMS/countpuser.do",
	       type : "get",
	       success : function (m) {
	      	  arry = JSON.parse(m);
	      	  cc = arry["counts"];
	      	  
			 }
		});
	}
    
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><span>青鸟影院管理系统</span></div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="updateAdmin.html" >
                   	 <img src="${pageContext.request.contextPath}/img/default.png" class="layui-nav-img layui-anim layui-anim-rotate"/>
                   	 <span id="user_name"></span>
                </a>
            </li>
              <li class="layui-nav-item"><a href="adminNo">退出</a></li>
        </ul>
    </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test" id="leftside">
                    <script id="side" type="text/html">
                        {{#  layui.each(d.list, function(index, item){ }}
                        <li class="layui-nav-item">
                            <a href="{{item.url}}"><i class="layui-icon {{item.icon}}"></i> {{item.name}}</a>
                        </li>
                        {{#  }); }}
                        {{#  if(d.list.length === 0){ }}
                        无数据
                        {{#  } }}
                    </script>
                </ul>
            </div>
        </div>
        <div class="layui-body">
            <!-- 主体区域开始 -->
            <!--当前位置开始-->
            <div class="layui-card layadmin-header">
                <span class="layui-breadcrumb">
                      <a href="AdminIndex">系统</a>
                      <a><cite>用户管理</cite></a>
                </span>
            </div>
            <!--当前位置结束-->
            <div class="layui-row">
                <div id="system" style="height: 400px">
                    <div class="head">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline" style="width: 200px;">
                                        <input type="text" id="names" lay-verify="required" placeholder="请输入姓名" lay-verType="tips" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn layui-btn-radius" id="btns">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                                    </button>
                                </div>
                            </div>
                    </div>
                    
                    <table class="layui-table">
                        <thead>
                            <tr>
                                <td>全选</td>
                                <td>序号</td>
                                <td>头像</td>
                                <td>会员昵称</td>
                                <td>手机号</td>
                                <td>会员类型</td>
                                <td>折扣</td>
                                <td>识别码</td>
                                <td style="width: 118px;">操作</td>
                            </tr>
                        </thead>
                        <tbody id="td">
                            <c:forEach items="${members}" var="member" varStatus="status">
                                <tr>
                                    <td><input type="checkbox" name="names" value="${member.memberName}"></td>
                                    <td>${status.index+1}</td>
                                    <td><img src="${member.memberHead}" alt="青鸟" class="userhead"></td>
                                    <td>${member.memberName}</td>
                                    <td>${member.memberPhone}</td>
                                    <td><c:choose>
                                        <c:when test="${member.memberTemp==0}">
                                            大众会员
                                        </c:when>
                                        <c:otherwise>
                                            普通会员
                                        </c:otherwise>
                                    </c:choose></td>
                                    <td>${member.memberDiscount}</td>
                                    <td>${member.memberMunber}</td>
                                    <td>
                                        <a href="UserUpdate?memberName=${member.memberName}" class="layui-btn layui-btn-xs"><i class="layui-icon layui-icon-edit"></i>修改</a>
                                        <a href="UserDelete?names=${member.memberName}" class="layui-btn layui-btn-danger layui-btn-xs" rel="1" class="user_del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                                    </td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </table>
                    <!-- 页码128 -->
                    <div id="yeNum">
                        <div id="page"></div>
                    </div>
                    <script type="text/javascript" src="${pageContext.request.contextPath}/js/page.js"></script>
                    <script type="text/javascript">

                        //页数pageTotal代表总页数,curPage当前页数,paginationId加载页面的id,shou首页,wei尾页,shan上一页,xia下一页,sznum数字跳转
                        var num = ${pages.pages};//'总页数';
                        var page =${pages.pageNum};// '当前页数';
                        var shous ="Users" ;//'超链接首页'
                        var weis ="Users?pageNum=${pages.pages}" ;//'超链接尾页'
                        if (${pages.hasPreviousPage}){
                            var shans ="Users?pageNum=${pages.pageNum-1}"; //'超链接上一页'
                        }else{
                            var shans ="Users"; //'超链接上一页'
                        }
                        if (${pages.hasNextPage}){
                            var xias = "Users?pageNum=${pages.pageNum+1}";//'超链接下一页'
                        }else{
                            var xias ="Users?pageNum=${pages.pages}"; //'超链接下一页'
                        }

                        var pages={pageTotal:num,curPage:page,paginationId:"",shou:shous,wei:weis,shan:shans,xia:xias,sznum:"Users?pageNum="};
                        //调用page.js里的方法
                        dynamicPagingFunc(pages);
                    </script>
                </div>
                <div id="moreMenu">
                    <a href="UserDelect?name=${member.memberName}" class="layui-btn layui-btn-danger layui-btn-xs" rel="1" class="user_del"><i class="layui-icon layui-icon-delete"></i>批量删除</a>
                    <a href="UserAdd" class="layui-btn layui-btn-xs"><i class="layui-icon layui-icon-add-1"></i>添加</a>
                </div>
            </div>
            <!--主体区域结束-->
        </div>
      <div class="layui-footer" style="text-align:center">
        <!-- 底部固定区域 -->
        © 版权管理
    </div>
    </div>
    <script src="${pageContext.request.contextPath}/js/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
    <script src="${pageContext.request.contextPath}/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.cookie.js"></script>
    
    <script type="text/javascript">

    function linklist(arry) {
    	var num = 1;
    	for(var i in map){
    		str +="<tr>";
    		str +="<td>"+(num++)+"</td>";
    		str +="<td>"+arry[i]["memberName"]+"</td>";
    		str +="<td>"+arry[i]["sex"]+"</td>";
    		str +="<td>"+arry[i]["iphone"]+"</td>";
    		str +="<td>"+arry[i]["email"]+"</td>";
    		str +="<td><img src='${pageContext.request.contextPath}/img/abc.jpg' class='userhead'></td>";
    		if(arry[i]["states"]=='正常'){
    			str +="<td><span class='layui-badge layui-bg-green'>"+arry[i]["states"]+"</span></td>";
    		}else{
    			str +="<td><span class='layui-badge layui-bg-red'>"+arry[i]["states"]+"</span></td>";
    		}
    		str +="<td> <a href='UsersUpdate?id="+arry[i]["id"]+"' class='layui-btn layui-btn-xs'><i class='layui-icon layui-icon-edit'></i>修改</a>";
    		str +="<a class='layui-btn layui-btn-danger layui-btn-xs delpuser' rel='"+arry[i]["id"]+"'><i class='layui-icon layui-icon-delete'></i>删除</a>";
    	}
    }
    
    function del_puser() {
        $(".delpuser").click(function(){
        	var ids = $(this).attr("rel");
            layer.open({
                icon:3,
                content:"确认删除 ID 为："+$(this).attr("rel")+" 的信息吗？",
                title:"确认删除",
                btn: ['确定', '取消'],
                yes: function(index, layero){
            		$.ajax({
           			 url : "/SSM_CMS/delPUser.do",
           	         type : "post",
           	         data:{
           	        	 "result" : ids,
           	         },
           	         success : function (m) {
           	        	 var arry = JSON.parse(m);
           	        	 console.log(arry);
           	        	 if(arry.state==1){
           	        		layer.msg("删除成功",{
           	                    icon:1,time:2000
           	                });
           	        		 setTimeout("location.href='users.html'",1000);
           	        	 }else{
           	        		 layer.msg('删除失败', {icon: 5,time: 800});
           	        	 }
           	         }
           		});
                    
                }
                ,btn2: function(index, layero){
                    layer.msg("已取消",{
                        icon:2,time:1000
                    });
                }
            });
            return false;
        });
    }
    
    
    $('#btns').click(function () {
    	var names = $('#names').val();
    	if(names.trim().length==0){
    		location.href="Users";
    	}else{
    		location.href="searchUser?userName="+names;
    	}
    	
	});
    </script>
</body>
</html>
